<?php

/**
 * This is the model class for table "automaticfiresuppression".
 *
 * The followings are the available columns in table 'automaticfiresuppression':
 * @property integer $Id
 * @property string $TypeOfExtinguishingAgent
 * @property double $JockeyPumpCapacityHp
 * @property double $JockeyPumpCapacityGpm
 * @property double $FirePumpCapacityHp
 * @property double $FirePumpCapacityGpm
 * @property double $TankCapacity
 * @property string $MaintainingLinePressure
 * @property string $FarthestSprinklerHeadPressure
 * @property double $RiserSize
 * @property string $TypeOfHeadsInstalled
 * @property integer $NoOfHeads
 * @property integer $Total
 * @property string $SpacingOfHeads
 * @property string $LocationOfFireDepartmentConnection
 * @property string $DateLastTested
 * @property string $ConductedBy
 * @property string $PlanSubmitted
 * @property string $CertificationOfInstallation
 * @property integer $Establishment_Id
 *
 * The followings are the available model relations:
 * @property Establishments $establishment
 */
class Automaticfiresuppression extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Automaticfiresuppression the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'automaticfiresuppression';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('NoOfHeads, Total, Establishment_Id', 'numerical', 'integerOnly'=>true),
			array('JockeyPumpCapacityHp, JockeyPumpCapacityGpm, FirePumpCapacityHp, FirePumpCapacityGpm, TankCapacity, RiserSize', 'numerical'),
			array('TypeOfExtinguishingAgent, MaintainingLinePressure, FarthestSprinklerHeadPressure, SpacingOfHeads', 'length', 'max'=>45),
			array('TypeOfHeadsInstalled', 'length', 'max'=>60),
			array('ConductedBy, PlanSubmitted, CertificationOfInstallation', 'length', 'max'=>100),
			array('LocationOfFireDepartmentConnection, DateLastTested', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('Id, TypeOfExtinguishingAgent, JockeyPumpCapacityHp, JockeyPumpCapacityGpm, FirePumpCapacityHp, FirePumpCapacityGpm, TankCapacity, MaintainingLinePressure, FarthestSprinklerHeadPressure, RiserSize, TypeOfHeadsInstalled, NoOfHeads, Total, SpacingOfHeads, LocationOfFireDepartmentConnection, DateLastTested, ConductedBy, PlanSubmitted, CertificationOfInstallation, Establishment_Id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'establishment' => array(self::BELONGS_TO, 'Establishments', 'Establishment_Id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'Id' => 'ID',
			'TypeOfExtinguishingAgent' => 'Type Of Extinguishing Agent',
			'JockeyPumpCapacityHp' => 'Jockey Pump Capacity Hp',
			'JockeyPumpCapacityGpm' => 'Jockey Pump Capacity Gpm',
			'FirePumpCapacityHp' => 'Fire Pump Capacity Hp',
			'FirePumpCapacityGpm' => 'Fire Pump Capacity Gpm',
			'TankCapacity' => 'Tank Capacity',
			'MaintainingLinePressure' => 'Maintaining Line Pressure',
			'FarthestSprinklerHeadPressure' => 'Farthest Sprinkler Head Pressure',
			'RiserSize' => 'Riser Size',
			'TypeOfHeadsInstalled' => 'Type Of Heads Installed',
			'NoOfHeads' => 'No Of Heads',
			'Total' => 'Total',
			'SpacingOfHeads' => 'Spacing Of Heads',
			'LocationOfFireDepartmentConnection' => 'Location Of Fire Department Connection',
			'DateLastTested' => 'Date Last Tested',
			'ConductedBy' => 'Conducted By',
			'PlanSubmitted' => 'Plan Submitted',
			'CertificationOfInstallation' => 'Certification Of Installation',
			'Establishment_Id' => 'Establishment',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('Id',$this->Id);
		$criteria->compare('TypeOfExtinguishingAgent',$this->TypeOfExtinguishingAgent,true);
		$criteria->compare('JockeyPumpCapacityHp',$this->JockeyPumpCapacityHp);
		$criteria->compare('JockeyPumpCapacityGpm',$this->JockeyPumpCapacityGpm);
		$criteria->compare('FirePumpCapacityHp',$this->FirePumpCapacityHp);
		$criteria->compare('FirePumpCapacityGpm',$this->FirePumpCapacityGpm);
		$criteria->compare('TankCapacity',$this->TankCapacity);
		$criteria->compare('MaintainingLinePressure',$this->MaintainingLinePressure,true);
		$criteria->compare('FarthestSprinklerHeadPressure',$this->FarthestSprinklerHeadPressure,true);
		$criteria->compare('RiserSize',$this->RiserSize);
		$criteria->compare('TypeOfHeadsInstalled',$this->TypeOfHeadsInstalled,true);
		$criteria->compare('NoOfHeads',$this->NoOfHeads);
		$criteria->compare('Total',$this->Total);
		$criteria->compare('SpacingOfHeads',$this->SpacingOfHeads,true);
		$criteria->compare('LocationOfFireDepartmentConnection',$this->LocationOfFireDepartmentConnection,true);
		$criteria->compare('DateLastTested',$this->DateLastTested,true);
		$criteria->compare('ConductedBy',$this->ConductedBy,true);
		$criteria->compare('PlanSubmitted',$this->PlanSubmitted,true);
		$criteria->compare('CertificationOfInstallation',$this->CertificationOfInstallation,true);
		$criteria->compare('Establishment_Id',$this->Establishment_Id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}